package com.rgz.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rgz.pojo.User;
import com.rgz.service.UserService;

@Controller
@RequestMapping("user")
public class UserController {
    @Autowired  
	private UserService userService;
	
	 @RequestMapping("/login.do")
	  public String login(){
		  return "login";
	  }
	 
	 @RequestMapping("/dologin.html")
	 public String dologin(User user,HttpSession session){
		 //����userService�е��ж��û��Ƿ���ڵķ���
		 boolean flag=userService.login(user);
		 if (flag) {
			 session.setAttribute("username",user.getUsernameQ());
			 return "redirect:/getBookList2";
			 
		}else{
			
			throw new RuntimeException("用户名或密码输入错误");
			
		}
		 
	 }
	 
	 
/*	 @ExceptionHandler(value=RuntimeException.class)
	 public String handlerException(RuntimeException e,HttpServletRequest req){
		 
		 req.setAttribute("e", e);
		 
		return "error"; 
	 };*/
	 
	 
	 
	 
	 
	 
	 
	
	
}
